@extends('layouts.userctl')
@section('content')
<style>
	.formpage {
		width: 60%;
		height: auto;
		margin: 10px auto;
	}
	.layui-form-label{
		width: 150px;
	}
	.layui-input-block{
		margin-left: 150px;
	}
</style>
<div class="formpage">
	<form class="layui-form" action="{{route('admin.msg.addmsg')}}" method="post" onkeypress="return event.keyCode != 13;">
		{{csrf_field()}}
		<div class="layui-form-item">
			<label class="layui-form-label">接收人</label>
			<div class="layui-input-block">
				<select name="userid" lay-filter="recvdiv"lay-search>
					<option value="">请选择消息接收人</option>
					@foreach($users as $user)
					<option value="{{$user->id}}">{{$user->name}}</option>
					@endforeach
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">消息标题</label>
			<div class="layui-input-block">
				<input type="text" name="title" required lay-verify="required" placeholder="消息标题" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">消息内容</label>
			<div class="layui-input-block">
				<textarea name="content" placeholder="在此输入消息内容" class="layui-textarea" required lay-verify="required"></textarea>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即发送</button>
				<button class="layui-btn layui-btn-primary" id="backpage">返 回</button>
			</div>
		</div>
	</form>
</div>
<script>
	//Demo
layui.use('form', function() {
	var form = layui.form
	$('#backpage').click(function() {
		history.back(-1)
	})
	//监听提交
	form.on('submit(formDemo)', function(data) {
		var index = layer.load(0, { shade:false })
	})
})
</script>

@endsection
